package com.campus.campus.controller;

import com.campus.campus.job.dto.TimeFeeDTO;
import com.campus.campus.service.IUtilityBillsService;
import com.campus.common.recharge.service.IRechargeRecordsService;
import com.campus.common.result.Result;
import com.campus.campus.service.IUtilityConsumptionRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@RequestMapping("/campusFee")
@Tag(name = "校园费用去向服务")
public class FeeController {

    @Autowired
    private IUtilityBillsService utilityBillsService;

    @Autowired
    private IRechargeRecordsService rechargeRecordsService;

    @Autowired
    private IUtilityConsumptionRecordService utilityConsumptionRecordService;


    @PostMapping("/insertElectronicFee")
    @Operation(summary = "充值电费")
    public Result InsertElectronicFeeInfoFun(@RequestParam BigDecimal fee){
        return utilityBillsService.InsertElectronicFee(fee);
    }

    @PostMapping("/insertWaterFee")
    @Operation(summary = "充值水费")
    public Result InsertWaterFeeInfoFun(@RequestParam("fee") BigDecimal fee){
        return utilityBillsService.InsertWaterFee(fee);
    }
    @Operation(summary = "充值校园卡")
    @PostMapping("/insertCampusCard")
    public Result InsertCampusCard(@RequestParam BigDecimal fee){
        return utilityBillsService.InsertCampusCard(fee);
    }



    @PostMapping("/getStatistics")
    @Operation(summary = "获取统计信息")
    public Result getElectricityStatistics(@RequestBody TimeFeeDTO timeFeeDTO){
        return utilityBillsService.getElectricityStatistics(timeFeeDTO);
    }

    @GetMapping("/getRechargeRecords")
    @Operation(summary = "获取充值记录统计信息")
    public Result getRechargeRecords(){
        return rechargeRecordsService.getRechargeStatic();
    }

    @Operation(summary = "获取今日用水量")
    @GetMapping("/getTodayUsage")
    public Result getTodayUsageInfo(@RequestParam(defaultValue = "水费") String type){
        return utilityConsumptionRecordService.getTodayUsage(type);
    }

    @Operation(summary = "剩余电量")
    @GetMapping("/getElectricity")
    public Result getElectricity(){
        return utilityBillsService.getElectricity();
    }

    @Operation(summary = "获取年度水费")
    @GetMapping("/getWaterTotalFee")
    public Result getWaterTotalFeeFun(@RequestParam String type){
        return utilityBillsService.getWaterTotalFee(type);
    }

}
